﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：FundsOperatingTypeInfo
// 文件功能描述：增减款类别
//
// 
// 创建标识：2012-02-23 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class FundsOperatingTypeInfo
    {
        /// <summary>
        /// 主键，类别编号
        /// </summary>
        public int DepositTypeID
        {
            get;
            set;
        }
        /// <summary>
        /// 类别名称
        /// </summary>
        public string DepositName
        {
            get;
            set;
        }
        /// <summary>
        /// 类型(0、1)
        /// </summary>
        public int Account
        {
            get;
            set;
        }
        /// <summary>
        /// 类型(增款类型、减款类型)
        /// </summary>
        public string AccountName
        {
            get;
            set;
        }
        /// <summary>
        /// 是否使用中(0、1)
        /// </summary>
        public int bUse
        {
            get;
            set;
        }
        /// <summary>
        /// 是否使用中(是、否)
        /// </summary>
        public string bUseName
        {
            get;
            set;
        }
        /// <summary>
        /// 是否显示布尔型
        /// </summary>
        public bool blBShow
        {
            get;
            set;
        }
        /// <summary>
        /// 是否显示
        /// </summary>
        public string bShowName
        {
            get;
            set;
        }

        private DataAccessFundsOperatingType dar;
        private int FundsOperatingTypecount;
        public int _FundsOperatingTypecount
        {
            get { return FundsOperatingTypecount; }
        }
        public FundsOperatingTypeInfo(bool isgetcount)
        {
            dar = new DataAccessFundsOperatingType();
            if (isgetcount)
            {
                FundsOperatingTypecount = GetFundsOperatingTypeCount();
            }
        }
        public FundsOperatingTypeInfo()
        { }
        /// <summary>
        /// 获取增减款类别数量
        /// </summary>
        /// <returns></returns>
        private int GetFundsOperatingTypeCount()
        {
            return dar.GetFundsOperatingTypeCount();
        }

        /// <summary>
        /// 获取增减款类别信息（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<FundsOperatingTypeInfo> SelFundsOperatingTypeInfo(int pagesize, int startindex, string strquery)
        {
            IList<FundsOperatingTypeInfo> fundlist = new List<FundsOperatingTypeInfo>();
            FundsOperatingTypeInfo fundinfo;
            DataSet ds = dar.SelFundsOperatingTypeInfo(pagesize, startindex, strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                fundinfo = new FundsOperatingTypeInfo()
                {
                    DepositTypeID = Convert.ToInt32(item["DepositTypeID"]),
                    DepositName = item["DepositName"].ToString(),
                    AccountName = item["AccountName"].ToString(),
                    bUseName = item["bUseName"].ToString(),
                    bShowName = item["bShowName"].ToString(),
                };
                fundlist.Add(fundinfo);
            }
            return fundlist;
        }

        /// <summary>
        /// 删除增减款类别
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public int DeleteFundsOperatingType(string ID)
        {
            return dar.DeleteFundsOperatingType(ID);
        }
        /// <summary>
        /// 检查是否为系统保留项
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int SelFundsOperatingTypeEdit(string ID)
        {
            return dar.SelFundsOperatingTypeEdit(ID);
        }

        /// <summary>
        /// 保存增减款类别(新增界面下)
        /// </summary>
        /// <param name="rolepara"></param>
        /// <returns></returns>
        public int SaveFundsOperatingType(FundsOperatingTypeInfo fund)
        {
            object[] obj = new object[] { fund.DepositTypeID, fund.DepositName, fund.Account, fund.bUse, fund.blBShow };
            return dar.SaveFundsOperatingType(obj);
        }

        /// <summary>
        /// 根据编号获取一条增减款类别信息
        /// </summary>
        /// <param name="supplierNo"></param>
        /// <returns></returns>
        public FundsOperatingTypeInfo GetFundsOperatingTypeInfoOne(string ID)
        {
            dar = new DataAccessFundsOperatingType();
            DataSet ds = dar.GetFundsOperatingTypeInfoOne(ID);
            FundsOperatingTypeInfo info = new FundsOperatingTypeInfo();
            info.DepositTypeID = int.Parse(ds.Tables[0].Rows[0]["DepositTypeID"].ToString());
            info.DepositName = ds.Tables[0].Rows[0]["DepositName"].ToString();
            info.Account = int.Parse(ds.Tables[0].Rows[0]["Account"].ToString());
            info.bUse = int.Parse(ds.Tables[0].Rows[0]["bUse"].ToString());
            info.blBShow = Convert.ToBoolean(ds.Tables[0].Rows[0]["bShow"]);
            return info;
        }

        /// <summary>
        /// 保存增减款类别(修改界面下)
        /// </summary>
        /// <param name="rolepara"></param>
        /// <returns></returns>
        public int SaveFundsOperatingTypeEdit(FundsOperatingTypeInfo fund)
        {
            object[] obj = new object[] { fund.DepositTypeID, fund.DepositName, fund.Account, fund.bUse, fund.blBShow };
            return dar.SaveFundsOperatingTypeEdit(obj);
        }

        public bool CheckFundsOperatingType(int DepositTypeID)
        {
            int count = dar.CheckFundsOperatingType(DepositTypeID);
            return count > 0 ? false : true;
        }
    }
}
